package com.dg.controller;

import com.dg.common.ServerResponse;
import com.dg.param.DeptParam;
import com.dg.pojo.Dept;
import com.dg.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept/")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @RequestMapping("list")
    public ServerResponse<List<Dept>> list(){
        return ServerResponse.createBySuccess(deptService.list());
    }

    @RequestMapping("save")
    public ServerResponse<List<Dept>> save(DeptParam param){
        deptService.save(param);
        return ServerResponse.createBySuccess();
    }

    @RequestMapping("update")
    public ServerResponse update(DeptParam param){
        deptService.update(param);
        return ServerResponse.createBySuccess();
    }

    @RequestMapping("delete")
    public ServerResponse delete(Integer id){
        deptService.delete(id);
        return ServerResponse.createBySuccess();
    }




}
